<!-- extend base layout -->
{% extends "base.html" %}

{% block content %}

    <div class="jumbotron">
        <script type="text/javascript">
            //javascript 设置openid到输入框内
            function set_openid(openid, pr) {
                u = openid.search('<username>')
                if (u != -1) {
                    // openid requires username
                    user = prompt('Enter your ' + pr + ' username:')
                    openid = openid.substr(0, u) + user
                }
                form = document.forms['login'];
                form.elements['openid'].value = openid
            }
        </script>

        <div class="container">
            <form class="form-horizontal" action="" method="post" name="login">
                {{ form.hidden_tag() }}
                <h2 class="form-signin-heading">Sign In</h2>
                <p>
                    Please enter your OpenID, or select one of the providers below:<br>
                    {{ form.openid(class='form-control',size=50) }}
                    <!--显示openid的错误信息-->
                    {% for error in form.openid.errors %}
                        <span style="color: red;">[{{ error }}]</span>
                    {% endfor %}<br>
                    |
                    {% for pr in providers %}
                        {#显示配置文件内的openid字典#}
                        <a href="javascript:set_openid('{{ pr.url }}', '{{ pr.name }}');">{{ pr.name }}</a> |
                    {% endfor %}
                </p>
                <p>{{ form.remember_me }}Remember me?</p>
                <p><input class="btn btn-large btn-primary" type="submit" value="Sign In"></p>
            </form>
        </div>
    </div>
{% endblock %}